<template>
  <div class="container">
    <h3>用户列表</h3>
    <el-table :data="tableData" stripe>
      <el-table-column prop="userName" label="用户名"></el-table-column>
      <el-table-column prop="password" label="密码(hash)"></el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="handleView(scope.row)" type="text" size="small">
            查看
          </el-button>
          <el-button @click="handleUpdate(scope.row)" type="text" size="small">
            编辑
          </el-button>
          <el-button @click="handleDelete(scope.row)" type="text" size="small">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data () {
    return {
      tableData: []
    }
  },
  methods: {
    async initTableData () {
      try {
        const res = await this.$api.user.getUserList()
        this.tableData = res.data
      } catch (e) {
        console.log(e)
      }
    },
    handleView (row) {
      console.log(row)
    },
    handleUpdate (row) {
      console.log(row)
    },
    handleDelete (row) {
      console.log(row)
    }
  },
  mounted () {
    this.initTableData()
  }
}
</script>

<style lang="scss" scoped>
</style>
